package org.example.base.th;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;

public class CallableTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        FutureTask<String> task = new FutureTask<>(new MyThread());
        new Thread(task).start();

        String s = task.get();
        System.out.println("s = " + s);

        Lock lock;
    }

    static class MyThread implements Callable<String> {
        @Override
        public String call() throws Exception {
            TimeUnit.SECONDS.sleep(2);
            return "Hello World";
        }
    }
}
